package com.zr.d_c.serviceimpl;

import com.zr.d_c.dao.OrderDao;
import com.zr.d_c.daoimpl.OrderDaoImpl;
import com.zr.d_c.service.SellerOrderService;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

public class SellerOrderServiceImpl implements SellerOrderService{
	OrderDao order = new OrderDaoImpl();
	@Override
	public JSONObject getSellerCurrentOrder(int start, int pageSize, int sid) {
		JSONObject orders = new JSONObject();
		orders.put("total", order.selectOrdersCount(sid));
		orders.put("rows", JSONArray.fromObject(order.selectOrderBySid(sid, start, pageSize)));
		return orders;
	}
	@Override
	public int acceptOrderByOid(int oid) {
		
		return order.sellerAcceptOrderByOid(oid);
	}
	@Override
	public JSONObject getSellerHistoryOrder(int start, int pageSize, int sid) {
		JSONObject orders = new JSONObject();
		orders.put("total", order.selectHistoryOrdersCount(sid));
		orders.put("rows", JSONArray.fromObject(order.selectHistoryOrderBySid(sid, start, pageSize)));
		return orders;
	}
	@Override
	public JSONObject getSellerHistoryOrder(int start, int pageSize, int sid, String searchname) {
		JSONObject orders = new JSONObject();
		orders.put("total", order.selectHistoryOrdersCount(sid));
		orders.put("rows", JSONArray.fromObject(order.selectHistoryOrderBySid(sid, start, pageSize,searchname)));
		return orders;
	}
	@Override
	public JSONObject getSellerCurrentOrder(int start, int pageSize, int sid, String searchname) {
		JSONObject orders = new JSONObject();
		orders.put("total", order.selectOrdersCount(sid));
		orders.put("rows", JSONArray.fromObject(order.selectOrderBySid(sid, start, pageSize,searchname)));
		return orders;
	}
}
